<?php 
require_once substr(dirname(__FILE__),0,-1).'sub/init.php';
require_once ZEAI.'sub/conn.php';
$currfields = 'sex,photo_s,nickname';
require_once ZEAI.'m/my_chk_u.php';
if($row['photo_s']!=$cook_photo_s)setcookie("cook_photo_s",$row['photo_s'],time()+720000,"/",$_ZEAI['CookDomain']);
if($row['sex']!=$cook_sex)setcookie("cook_sex",$row['sex'],time()+720000,"/",$_ZEAI['CookDomain']);
$photo_s_url = (!empty($cook_photo_s))?UP.$cook_photo_s:RES.'photo_m'.$cook_sex.'.png';
$cook_nickname = trimhtml(dataIO($row['nickname'],'out'));
/***********************主体入口***************************/
$fid = intval($fid);
if(!ifint($fid)){alert('参数丢失',"lovetest.php");}else{
	$rowS = $db->ROW(__TBL_LOVETEST_BANK__,"pgbz,pgyj,subjsonstr,path_s,title,description","id=".$fid,'name');
	if ($rowS){
		$pgbz = dataIO($rowS['pgbz'],'wx');
		$pgyj = dataIO($rowS['pgyj'],'wx');
		$answerS = dataIO($rowS['subjsonstr'],'out');
		$answerS = json_decode($answerS);
		$path_s = $rowS['path_s'];
		$share_title = dataIO($rowS['title'],'out');
		$share_desc = dataIO($rowS['description'],'out');
		$path_s_url = UP.$path_s;
	}else{alert('试题库不存在或已经删除',"lovetest.php");}
	//查询得数
	$rtA = $db->query("SELECT score FROM ".__TBL_LOVETEST_ANSWER__." WHERE qid='$fid' AND uid='$cook_uid' ORDER BY id DESC LIMIT 1");
	$rowA = $db->fetch_array($rtA,'name');
	if(!$rowA)alert('本题您还没有提交测试结果！',"lovetest.php");
	$score = $rowA['score'];
	//分析结果
	$anums = count($answerS);
	if (is_array($answerS) && $anums>0){
		$tmp_outstr = '';
		$px = 0;
		for($j=0;$j<$anums;$j++) {
			$score1    = intval($answerS[$j]->s1);
			$score2 = intval($answerS[$j]->s2);
			if($score>=$score1 && $score<=$score2){$tmp_outstr = $answerS[$j]->v;$px = $j;}
		}
	}
}
$headertitle = '检测结果';?>
<!doctype html><html><head><meta charset="utf-8">
<title><?php echo $headertitle;?></title>
<?php echo HEADMETA; ?>
<meta name="x5-orientation" content="portrait">
<link href="<?php echo RES;?>m/css/m.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<script src="<?php echo RES;?>www_zeai_cn.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/m.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<link href="<?php echo HOST;?>/cache/zeaicolor.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<style>
.rTop{width:100%;height:29rem;position: relative;overflow:hidden;}
.rTop:after{width:200%;height:29rem;position:absolute;left:-50%;top:0;z-index:-2;content:'';border-radius:0 0 50% 50%;background-size:50%;background-color:<?php echo $_ZEAI['mob_mbcolor'];?>;background:-webkit-linear-gradient(315deg,rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,.2) 0%,<?php echo $_ZEAI['mob_mbcolor'];?> 100%);}
.titlespan{width:100%;position:fixed;left:0;top:0;line-height:5rem;font-size:1.6rem;display:inline-block;color:#fff;text-align:center}
.transparent{background:transparent;}
.box1{width:92%;background-color:#fefefe;border-radius:.8rem .8rem 1rem 1rem;margin:-24rem auto 0 auto;box-shadow:0 .5rem 1rem rgba(0,0,0,0.05);box-sizing:border-box;padding:1.6rem}
.uinfo{width:100%;height:4.4rem;text-align:left;margin-bottom:1rem;position:relative}
.uinfo img{width:4.4rem;height:4.4rem;border-radius:2.2rem;object-fit:cover;-webkit-object-fit:cover}
.uinfo b{position:absolute;top:1.5rem;left:5.5rem;}
.score{width:100%;text-align:left;}
.score b{font-size:2.8rem;color:<?php echo $_ZEAI['mob_mbcolor'];?>}
.score p{margin:.8rem 0;line-height:150%}
.tubiao{width:100%;display:flex;flex-wrap:wrap;flex-direction:row;margin-top:2rem;align-items:flex-end;}
.tubiao li{width:<?php echo 100/$anums;?>%;background-color:#666;position:relative;margin-top:2rem}
.tubiao li:first-child{border-top-left-radius:1rem}
.tubiao li:last-child{border-top-right-radius:1rem}
.tubiao li em{width:100%;text-align:center;position:absolute;top:-2.5rem;display:block;}
.tubiao li i{left:-webkit-calc(50% - .8rem);width:0;height:0;border-left:.8rem solid transparent;border-right:.8rem solid transparent;border-top:1rem solid <?php echo $_ZEAI['mob_mbcolor'];?>;position:absolute;top:-4.5rem;display:inline-block;}
.box2{width:92%;background-color:#fefefe;border-radius:1rem;margin:2rem auto 0 auto;box-sizing:border-box;padding:1.6rem 1.6rem 2rem 1.6rem;    box-shadow: 0 0 2.4rem rgb(0 0 0 / 8%);}
.box2 h3{color:#222;font-weight:bold;text-align:left;}
.box2 p{width:100%;text-align:left;background-color:#f8f8f8;box-sizing:border-box;padding:1.2rem 1.2rem 2rem;margin-top:1.5rem;border-radius:.4rem}
.box2 p em{color:#b5b5b5;margin-bottom:1rem}
button{margin:3rem auto;float:left;}
.btn55{width:48%;}
.btn40{width:39%;margin-right:5%;margin-left:4%;}
/*share_maskfull*/
#share_mask{display:none}
#share_box{width:100%;position:fixed;top:0px;right:0;z-index:998;display:none;text-align:right}
#share_box img{width:60%}
</style>
</head>
<body>
<?php if (is_weixin()){
	require_once ZEAI."api/weixin/jssdk.php";
	?>
	<script src="<?php echo RES;?>jweixin-1.2.0.js"></script>
	<script>wx.config({debug:false,appId: '<?php echo $signPackage["appId"];?>',timestamp: <?php echo $signPackage["timestamp"];?>,nonceStr: '<?php echo $signPackage["nonceStr"];?>',signature: '<?php echo $signPackage["signature"];?>',jsApiList:['hideMenuItems','onMenuShareTimeline','onMenuShareAppMessage','onMenuShareQQ','onMenuShareWeibo']});
	var share_title = '<?php echo $share_title; ?>',share_desc='<?php echo $share_desc; ?>',share_link='<?php echo HOST."/m/lovetest.php"; ?>',share_imgurl='<?php echo $path_s_url; ?>';
	wx.ready(function () {
		wx.onMenuShareAppMessage({title:share_title,desc:share_desc,link:share_link,imgUrl:share_imgurl});
		wx.onMenuShareTimeline({title:share_title,desc:share_desc,link:share_link,imgUrl:share_imgurl});
	});
    </script>
<?php }?>
<a class="goback" href="javascript:zeai.back();" style="position:fixed"><i class='ico'>&#xeaca;</i></a>
<span class="titlespan">测试结果</span>
<div class="rTop"></div>
<div class="box1">
	<div class="uinfo"><img src="<?php echo $photo_s_url;?>"><b><?php echo $cook_nickname; ?></b></div>
	<div class="score">
    	<b><?php echo $score;?>分</b>
        <p><?php echo $tmp_outstr;?></p>
        <div class="clear"></div>
    </div>
    <div class="tubiao">
    <?php
    for($j=0;$j<$anums;$j++) {
		$score1    = intval($answerS[$j]->s1);
		$score2 = intval($answerS[$j]->s2);?>
    	<li style="height:<?php echo 60+$j*$anums*10;?>px;background-color:rgba(<?php echo c16_rgb($_ZEAI['mob_mbcolor']);?>,<?php echo 0.2+$j*0.1;?>)"><em><?php echo ($score1==$score2)?$score1:$score1."~".$score2;?>分</em><?php if($px==$j){?><i class="breath"></i><?php }?></li>
    <?php }?>  
    </div>
	<div class="clear"></div>
</div>
<div class="clear"></div>
<div class="box2">
	<h3>综合解读</h3>
    <p><em>● 评估标准</em><?php echo $pgbz;?></p>
    <p><em>● 评估依据</em><?php echo $pgyj;?></p>
</div>
<button id="wxshare" class="btn size4 yuan HUANG btn40">我要分享</button>
<button class="btn size4 yuan zeaibg btn55" onClick="zeai.openurl('lovetest.php')">返回测试页</button>
<div id="share_mask" class="mask1"></div>
<div id="share_box"><img src="<?php echo RES;?>shareico.png"></div>
<script>
wxshare.onclick = function(){zeai.showSwitch('share_mask,share_box');}
share_mask.onclick = function(){zeai.showSwitch('share_mask,share_box');}
share_box.onclick = function(){zeai.showSwitch('share_mask,share_box');}
</script>
<div id="blankpage"></div>
<div id="backtop"><a href="#top" id="btmTopBtn"><i class="ico">&#xe60c;</i>顶部</a></div>
<?php require_once ZEAI.'m/TRnav.php';?>
</body>
</html>